package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FinanceAutobillException;
import com.ktgj.flight.service.IFinanceAutobillExceptionService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 财务自动对账结果Controller
 * 
 * @author ruoyi
 * @date 2022-06-15
 */
@RestController
@RequestMapping("/exception")
public class FinanceAutobillExceptionController extends BaseController
{
    @Autowired
    private IFinanceAutobillExceptionService financeAutobillExceptionService;

    /**
     * 查询财务自动对账结果列表
     */
    @PreAuthorize(hasPermi = "system:exception:list")
    @GetMapping("/list")
    public TableDataInfo list(FinanceAutobillException financeAutobillException)
    {
        startPage();
        List<FinanceAutobillException> list = financeAutobillExceptionService.selectFinanceAutobillExceptionList(financeAutobillException);
        return getDataTable(list);
    }

    /**
     * 导出财务自动对账结果列表
     */
    @PreAuthorize(hasPermi = "system:exception:export")
    @Log(title = "财务自动对账结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FinanceAutobillException financeAutobillException) throws IOException
    {
        List<FinanceAutobillException> list = financeAutobillExceptionService.selectFinanceAutobillExceptionList(financeAutobillException);
        ExcelUtil<FinanceAutobillException> util = new ExcelUtil<FinanceAutobillException>(FinanceAutobillException.class);
        util.exportExcel(response, list, "财务自动对账结果数据");
    }

    /**
     * 获取财务自动对账结果详细信息
     */
    @PreAuthorize(hasPermi = "system:exception:query")
    @GetMapping(value = "/{billExceptionId}")
    public AjaxResult getInfo(@PathVariable("billExceptionId") Long billExceptionId)
    {
        return AjaxResult.success(financeAutobillExceptionService.selectFinanceAutobillExceptionById(billExceptionId));
    }

    /**
     * 新增财务自动对账结果
     */
    @PreAuthorize(hasPermi = "system:exception:add")
    @Log(title = "财务自动对账结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FinanceAutobillException financeAutobillException)
    {
        return toAjax(financeAutobillExceptionService.insertFinanceAutobillException(financeAutobillException));
    }

    /**
     * 修改财务自动对账结果
     */
    @PreAuthorize(hasPermi = "system:exception:edit")
    @Log(title = "财务自动对账结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FinanceAutobillException financeAutobillException)
    {
        return toAjax(financeAutobillExceptionService.updateFinanceAutobillException(financeAutobillException));
    }

    /**
     * 删除财务自动对账结果
     */
    @PreAuthorize(hasPermi = "system:exception:remove")
    @Log(title = "财务自动对账结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billExceptionIds}")
    public AjaxResult remove(@PathVariable Long[] billExceptionIds)
    {
        return toAjax(financeAutobillExceptionService.deleteFinanceAutobillExceptionByIds(billExceptionIds));
    }
}
